<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
class TestingUserRecord extends BaseModel
{
    protected $table = 'testing_user_record';
    protected $fillable = ['uid','tid','answers','score','final_answers','conclusion','advince_ids','created_at','testtime','nick_name','testing_name','from_appid','from_partner','order_id','nutritionist_id','free_order_id','virtual_oid'];


    public function decreaseWeight($tid,$appid){
        if($appid){
            return $this->where('from_appid',$appid)->where('tid',$tid);
        }else{
            return $this->where('tid',$tid);
        }
    }

    public function user(){
        return $this->belongsTo(WechatUser::class,'uid');
    }
    
    public function detail(){
        return $this->belongsTo(TestingDetail::class,'tid');
    }
}
